<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 一个数组，过滤掉最大的数和最小的数，然后再求平均值，用挂在原型上的方式
        const arr = [8, 12, 13, 15, 20,30]
        Array.prototype.guolv = function () {
            // console.log(this);
            max = Math.max(...this)
            min = Math.min(...this)
            // console.log(max)
            // console.log(min)
            const arr1 = this.filter(item => item !== max && item !== min)
            console.log(arr1);
            const arr2 = arr1.reduce((prev, item) => prev + item / arr1.length, 0)
            console.log(arr2);
        }
        arr.guolv()
        // console.log(arr2);
        // console.log(...arr)
    </script>
</body>

</html>